package com.ljw.punishment.enginelistener;

import com.ljw.punishment.baserule.AndRelationGroup;
import com.ljw.punishment.baserule.CommonRule;
import com.ljw.punishment.baserule.OrRelationGroup;
import org.jeasy.rules.api.Rule;

public class PrintRuleHelper {

    public static String printRule(String head, Rule rule) {
        StringBuilder stringBuilder = new StringBuilder(head).append(":【");

        if (rule instanceof AndRelationGroup) {
            AndRelationGroup andRelationGroup = (AndRelationGroup) rule;
            stringBuilder.append(andRelationGroup);
        } else if (rule instanceof OrRelationGroup) {
            OrRelationGroup andRelationGroup = (OrRelationGroup) rule;
            stringBuilder.append(andRelationGroup);
        } else if (rule instanceof CommonRule) {
            CommonRule andRelationGroup = (CommonRule) rule;
            stringBuilder.append(andRelationGroup);
        } else {
            stringBuilder.append(rule);
        }

        stringBuilder.append("】");

        return stringBuilder.toString();
    }
}
